package com.sh3h.generator.web.utils;

import com.mysql.cj.MysqlConnection;
import com.sh3h.generator.web.domain.GenDataSource;
import oracle.jdbc.driver.OracleConnection;
import org.springframework.util.StringUtils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * DB工具类
 *
 * @author 阿沐 babamu@126.com
 * <a href="https://maku.net">MAKU</a>
 */
public class DbUtils {
    private static final int CONNECTION_TIMEOUTS_SECONDS = 6;
    /**
     * 获得数据库连接
     */
    public static Connection getConnection(String driverClass,String connUrl,String username,String password) throws ClassNotFoundException, SQLException {
        DriverManager.setLoginTimeout(CONNECTION_TIMEOUTS_SECONDS);
        Class.forName(driverClass);
        Connection connection = DriverManager.getConnection(connUrl, username, password);
        return connection;
    }
}